home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / doom / quake.zip / HIPGRAPL.ZIP / HIPHOLES.QC < prev    next >
Text File  |  1997-01-30  |  3KB  |  114 lines

  1. /* Bullet holes QuickC program
  2.    By Jim Dose'  11/20/96
  3.    Copyright (c)1996 Hipnotic Interactive, Inc.
  4.    All rights reserved.
  5.    Do not distribute.
  6. */
  7.  
  8. /*QUAKED wallsprite (0 1 0) (-8 -8 -8) (8 8 8)
  9. Places a sprite on a wall.  Angles should be opposite of face.
  10.  
  11. "model" sprite to place on wall.  Default is "progs/s_blood1.spr".
  12. */
  13. void() wallsprite =
  14.    {
  15.    if ( !self.model )
  16.       {
  17.       self.model = "progs/s_blood1.spr";
  18.       }
  19.  
  20.    precache_model( self.model );
  21.    setmodel (self, self.model );
  22.  
  23.    // QuakeEd doesn't save up and down angles properly.
  24.    if (self.angles == '0 -1 0')
  25.       self.angles = '-90 0 0';
  26.     else if (self.angles == '0 -2 0')
  27.       self.angles = '90 0 0';
  28.  
  29.    // Pull the sprite away from the wall slightly to
  30.    // get rid of z sort errors.
  31.    makevectors(self.angles);
  32.    setorigin( self, self.origin - ( v_forward * 0.2 ) );
  33.     makestatic (self);
  34.    };
  35.  
  36. void() InitBulletHoles =
  37.    {
  38.    precache_model ("progs/s_bullet.spr");
  39.  
  40.    bulletholes = nullentity;
  41.    lastbullet = nullentity;
  42.    numbulletholes = 0;
  43.    };
  44.  
  45. void() remove_bullethole =
  46.    {
  47.    local entity ent;
  48.  
  49.    // There is a possibility that this is not the first bullet
  50.    // in the list, but it doesn't really matter.  All that
  51.    // matters is there is one less bullet.  Just make sure
  52.    // we don't remove the world!
  53.    if ( bulletholes == nullentity )
  54.       {
  55.       objerror("remove_bullethole: bulletholes == nullentity! " );
  56.       }
  57.  
  58.    ent = bulletholes;
  59.    if ( ent.classname != "bullethole" )
  60.       {
  61.       objerror("remove_bullethole: Tried to remove non-bullethole!" );
  62.       }
  63.  
  64.    bulletholes = bulletholes.lastvictim;
  65.    remove( ent );
  66.    if ( lastbullet == ent )
  67.       {
  68.       lastbullet = nullentity;
  69.       }
  70.    numbulletholes = numbulletholes - 1;
  71.    };
  72.  
  73. void( vector pos ) placebullethole =
  74. {
  75.    local entity new;
  76.    local entity ent;
  77.    local vector norm;
  78.  
  79.    new = spawn();
  80.    new.owner = new;
  81.    new.movetype = MOVETYPE_NONE;
  82.    new.solid = SOLID_NOT;
  83.    new.classname = "bullethole";
  84.    setmodel( new, "progs/s_bullet.spr" );
  85.    setsize (new, '0 0 0', '0 0 0');
  86.  
  87.    norm = trace_plane_normal;
  88.    norm_x = 0 - norm_x;
  89.    norm_y = 0 - norm_y;
  90.    new.angles = vectoangles( norm );
  91.    makevectors(self.angles);
  92.    setorigin( new, pos - ( v_forward * 0.2 ) );
  93.  
  94.    new.think = remove_bullethole;
  95.    new.nextthink = time + 300;
  96.  
  97.    numbulletholes = numbulletholes + 1;
  98.    if ( numbulletholes > 10 )
  99.       {
  100.       remove_bullethole();
  101.       }
  102.  
  103.    if ( lastbullet != nullentity )
  104.       {
  105.       lastbullet.lastvictim = new;
  106.       }
  107.    else
  108.       {
  109.       bulletholes = new;
  110.       }
  111.    new.lastvictim = nullentity;
  112.    lastbullet = new;
  113.    };
  114.